local t = Def.ActorFrame {}
local sGame = GAMESTATE:GetCurrentGame():GetName()
--local sType == GAMESTATE:GetCurrentStyle():GetStepsType()
local gamebutton = {}

--max 4 gamebuttons
if sGame == "pump" then
	gamebutton = {"UpLeft", "UpRight", "DownLeft", "DownRight"}
elseif sGame == "dance" then
	gamebutton = {"Up", "Down", "Left", "Right"}
end
--experimental session:
--or (sGame == "techno" and stype == 'StepsType_Techno_Single4|5')
--4 for dance, 5 for pump

--me acuerdo cuando no entendía nada de estos rollos
local ArrowPositions = {
	SCREEN_LEFT+82,		--// 1, 3
	SCREEN_RIGHT-82,	--// 2, 4
	SCREEN_TOP+70,		--// 1, 2
	SCREEN_BOTTOM-25	--// 3, 4
}

local ArrowFramePositions = {
	SCREEN_LEFT+82,		--// 1, 3
	SCREEN_RIGHT-82,	--// 2, 4
	SCREEN_TOP+119,		--// 1, 2
	SCREEN_BOTTOM-74	--// 3, 4
}

local ArrowFrameRotation = {
	cmd(rotationy,180),
	cmd(),
	cmd(rotationx,180;rotationy,180),
	cmd(rotationx,180)
}

for i=1,#gamebutton do
	t[#t+1] = NOTESKIN:LoadActorForNoteSkin(gamebutton[i], "Tap Note", "default")..{
		Name="Arrow_"..gamebutton[i];
		InitCommand=function(self)
			--self:vertalign(math.ceil(i/2) == 1 and top or bottom);
			self:vertalign(top);
			self:zoom(1.5);
			if i == 1 then
				self:x(ArrowPositions[1]);
				self:y(ArrowPositions[3]);
			elseif i == 2 then
				self:x(ArrowPositions[2]);
				self:y(ArrowPositions[3]);
			elseif i == 3 then
				self:x(ArrowPositions[1]);
				self:y(ArrowPositions[4]);
			else
				self:x(ArrowPositions[2]);
				self:y(ArrowPositions[4]);
			end
		end;
		OnCommand=function(self)
			self:finishtweening();
			self:diffusealpha(0);
			self:sleep(0.1);
			self:rotationz(math.ceil(i/2) == 1 and 135 or -135);
			self:linear(0.3);
			self:rotationz(0);
			self:diffusealpha(1);
		end;
		PumpDifficultiesChangedMessageCommand=function(self,params)
			--local originalzoom = self:GetZoom();
			--self:finishtweening();
			if i == 1 and params.Dir == "Left" then
				(cmd(finishtweening;linear,0.1;addx,-20;addy,-20;linear,0.1;addx,20;addy,20))(self);
			end
			if i == 2 and params.Dir == "Right" then
				(cmd(finishtweening;linear,0.1;addx,20;addy,-20;linear,0.1;addx,-20;addy,20))(self);
			end
		end;
		SongDirectionChangedMessageCommand=function(self,params)
			if i == 3 and params.Dir < 0 then
				(cmd(finishtweening;linear,0.1;addx,-20;addy,20;linear,0.1;addx,20;addy,-20))(self);
			end
			if i == 4 and params.Dir > 0 then
				(cmd(finishtweening;linear,0.1;addx,20;addy,20;linear,0.1;addx,-20;addy,-20))(self);
			end
		end;
	}
	t[#t+1] = LoadActor("ARR-L")..{
		Name="Frame_"..gamebutton[i];
		InitCommand=function(self)
			if i == 1 then
				self:x(ArrowFramePositions[1]);
				self:y(ArrowFramePositions[3]);
				(ArrowFrameRotation[i])(self);
			elseif i == 2 then
				self:x(ArrowFramePositions[2]);
				self:y(ArrowFramePositions[3]);
				(ArrowFrameRotation[i])(self);
			elseif i == 3 then
				self:x(ArrowFramePositions[1]);
				self:y(ArrowFramePositions[4]);
				(ArrowFrameRotation[i])(self);
			else
				self:x(ArrowFramePositions[2]);
				self:y(ArrowFramePositions[4]);
				(ArrowFrameRotation[i])(self);
			end
		end;
		OnCommand=function(self)
			self:finishtweening();
			self:diffusealpha(0);
			self:sleep(0.2);
			self:addx(i%2 == 1 and -50 or 50);
			self:addy(math.ceil(i/2) == 1 and -50 or 50);
			self:linear(0.2);
			self:addx(i%2 == 1 and 50 or -50);
			self:addy(math.ceil(i/2) == 1 and 50 or -50);
			self:diffusealpha(1);
		end;
		PumpDifficultiesChangedMessageCommand=function(self,params)
			--copypaste
			--self:finishtweening();
			if i == 1 and params.Dir == "Left" then
				(cmd(finishtweening;linear,0.1;addx,-20;addy,-20;linear,0.1;addx,20;addy,20))(self);
			end
			if i == 2 and params.Dir == "Right" then
				(cmd(finishtweening;linear,0.1;addx,20;addy,-20;linear,0.1;addx,-20;addy,20))(self);
			end
		end;
		SongDirectionChangedMessageCommand=function(self,params)
			if i == 3 and params.Dir < 0 then
				(cmd(finishtweening;linear,0.1;addx,-20;addy,20;linear,0.1;addx,20;addy,-20))(self);
			end
			if i == 4 and params.Dir > 0 then
				(cmd(finishtweening;linear,0.1;addx,20;addy,20;linear,0.1;addx,-20;addy,-20))(self);
			end
		end;
	}

end

return t